import {Injectable} from '@nestjs/common';
import {Repository} from "typeorm";
import {ResultUtils} from "@/utils/resultUtils";
import {Company} from '@/entitys/base/company.entity';
import {BaseService} from "@/modules/_/base/base.service";
import {InjectRepository} from "@nestjs/typeorm";
import {CacheTokenService} from "@/modules/cache/service/cacheTokenService";
import {RequestService} from "@/modules/request/service/requestService";
import {User} from "@/entitys/base/user.entity";

@Injectable()
export class CompanyService extends BaseService {


    constructor(
        @InjectRepository(Company) private readonly Repository: Repository<Company>,
        private readonly RequestService: RequestService,
        private readonly CacheUtils: CacheTokenService,
    ) {
        super(Repository);
    }

    async queryList() {
        // 需要去映射 FilterEnum，排除异常的字段
        const user = await this.repository.find();
        if (user) {
            return ResultUtils.success(user);
        }
        return ResultUtils.error(null, "err", "");
    }

    async test() {

        // const user1 = await this.CacheUtils.getUser("f8fc99a4-a387-4364-8f5a-fab2f1d8a222");
        //
        // console.log(user1, "data")
        //
        // const user = new User();
        //
        // user.companyId = 1;
        //
        // console.log(await this.CacheUtils.setUser(user));

    }
}
